import Vue from "vue"
import Vuex from "vuex"

Vue.use(Vuex)

export default new Vuex.Store({
    state:{
        // list:[
        //     {id:1,userName:"关天天",comment:"自从用了vue，腰不酸了，腿不麻了，心脏也不跳了"},
        //     {id:2,userName:"洪小超",comment:"用了vue后感觉自己月入五万"}
        // ]
        list:JSON.parse(localStorage.getItem("comment")) || []
    },
    mutations:{
        ADD_COMMENT(state,value){
            state.list.unshift(value)
        },
        DEL_COMMENT(state,id){
            state.list = state.list.filter(item=>item.id != id)
        }
    }

})